from django.test import TestCase
from django.test.client import Client

"""
Testira standings chess stranu
"""
class StandingsTableFootballTestCase(TestCase):

    def setUp(self):
        pass

    def runTest(self):
        c = Client()
        c.login(username='kokan', password='123')
        
        response = c.get("/mdcs/standings/table_football/")
        self.failIf(response == None)
        self.failIf(response.context == None)
        self.failUnlessEqual(len(response.context), 2)
        
        self.failIf(response.context[0]["users"] == None)
        users = response.context[0]["users"]
        self.failUnlessEqual(len(users), 6)

        values = (
                  (5, "atomic", 1260),
                  (6, "milaki", 1260),
                  (9, "milann", 1215),
                  (10, "dragant", 1215),
                  (7, "mazi", 1125),
                  (8, "miradu", 1125))
        i = 0
        for id, username, points in values:
            self.failUnlessEqual(users[i].user.id, id)
            self.failUnlessEqual(users[i].user.username, username)
            self.failUnlessEqual(users[i].tf_points, points)
            i = i + 1
            
        response = c.get("/mdcs/standings/table_football/?all_users=on")
        self.failIf(response == None)
        self.failIf(response.context == None)
        self.failUnlessEqual(len(response.context), 2)
        
        self.failIf(response.context[0]["users"] == None)
        users = response.context[0]["users"]
        self.failUnlessEqual(len(users), 12)

        values = (
                  (5, "atomic", 1260),
                  (6, "milaki", 1260),
                  (9, "milann", 1215),
                  (10, "dragant", 1215),
                  (2, "kokan", 1200),
                  (3, "satom", 1200),
                  (4, "sttara", 1200),
                  (11, "migrbi", 1200),
                  (12, "milostod", 1200),
                  (13, "vvasic", 1200),
                  (7, "mazi", 1125),
                  (8, "miradu", 1125))
        i = 0
        for id, username, points in values:
            self.failUnlessEqual(users[i].user.id, id)
            self.failUnlessEqual(users[i].user.username, username)
            self.failUnlessEqual(users[i].tf_points, points)
            i = i + 1